<?php
// +----------------------------------------------------------------------
// | my
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2022 http://baiyf.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: $this <498944516@qq.com>
// +----------------------------------------------------------------------
namespace app\rob\model;

use think\Model;

class RobApp extends Model
{

    protected $table = "my_rob_app";
    protected $insert = ['status'=>1];  
    protected $autoWriteTimestamp = true;

    /**
     * 获取机器人
     */
    public function info($keyword,$data=[]){
    	
       $apps = $this->all($data['options']['app']);
       if ($apps){
    	      foreach ($apps as $key => $app) {
    	      	 if (strstr($keyword,$app->keyword)){
    	      	 	$data['app']=$app;
                $data['keyword']=$app->keyword;
    		        $data['before'] = substr($keyword,0,strrpos($keyword,$app->keyword));
    		        $data['back']=str_replace($data['before'].$app->keyword,"",$keyword);
    		        $reply=model('rob/RobAppDo')->index($data);
                return $reply;
    		     }  
    	      }
         }
    }

   



    public function editData(){

      $data=input("post.");
     
      if ($data['id']){
         $res = $this->allowField(true)->where('id',$data['id'])->update($data);
      }else{
         $data['aid']=session('aid');
         $res = $this->allowField(true)->data($data)->save();
      }
      
      return $res;
    }



    
}